package stark.app.frame.baseclassuse.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder;

import org.jetbrains.annotations.NotNull;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import stark.app.R;
import stark.app.databinding.ItemStkLoadMoreBinding;
import stark.common.api.StkApi;
import stark.common.base.IReqRetCallback;
import stark.common.basic.adapter.BaseLoadMoreAdapter;
import stark.common.bean.StkResourceBean;

/**
 * Author：daizhongbin on 2021/8/6
 * Email：1027154338@qq.com
 * Desc:
 */
public class StkLoadMoreAdapter extends BaseLoadMoreAdapter<StkResourceBean, ItemStkLoadMoreBinding> {

    public StkLoadMoreAdapter() {
        super(R.layout.item_stk_load_more, 0);
    }

    @Override
    protected void convert(@NotNull BaseDataBindingHolder<ItemStkLoadMoreBinding> holder, StkResourceBean stkResourceBean) {
        ImageView imageView = holder.getDataBinding().ivImg;
        Glide.with(imageView)
                .load(stkResourceBean.getThumbnail_url())
                .placeholder(R.drawable.ic_load_place_holder)
                .error(R.drawable.ic_load_place_holder)
                .into(imageView);
    }

    @Override
    protected void reqLoadData(int page, int pageSize, @NonNull ILoadDataCallback<StkResourceBean> callback) {
        //没事壁纸资源
        final String hashId = "peinMSSLaRB";
        StkApi.getTagResourceList(hashId, page, pageSize, null, new IReqRetCallback<List<StkResourceBean>>() {
            @Override
            public void onResult(boolean success, String msg, @Nullable List<StkResourceBean> result) {
                callback.onLoadedData(success, result);
            }
        });
    }
}
